<template>
  <LdbpPage
    pageName="szhgg"
    zh_name="数字化改革"
    :rankList_title="rankList_title"
    :rankList_th="rankList_th"
    :rankList_4="rankList_4"
    :rankList_6="rankList_6"
    :rankList_8="rankList_8"
    :info="info"
  ></LdbpPage>
</template>

<script>
import axios from 'axios'
import LdbpPage from '../../components/LdbpPage'

export default {
  name: 'Szhgg',
  components: { LdbpPage },
  data() {
    return {
      info: '数字化改革围绕党政机关整体智治，数字政府，数字经济，数字社会，数字法治五个综合应用以及围绕数字化改革和经济体制，民主体制，文化体制，社会体制，生态文明体制，党的建设，纪律检查体制开展实践，推进全方位，系统性，重塑性数字化改革。',
      rankList_title: ['特色亮点榜', '综合排名榜（牵头单位）', '综合排名榜（责任单位）', '综合排名榜（协同单位）', '综合排名榜（乡镇街道）'],
      rankList_th: [
        ['', '', '总分'],
        ['', '', '总分'],
        ['', '', '总分'],
        ['', '', '总分'],
        ['', '', '总分']
      ],
      rankList_4: [],
      rankList_6: [],
      rankList_8: [],
    };
  },
  mounted() {
    // 四月
    this.teSeLiangDian('4', 0) // 特色亮点榜
    this.qianTouDanWei('4', 1) // 牵头单位
    this.elseRank('1', '4', 2) // 责任单位
    this.elseRank('2', '4', 3) // 协同单位
    this.elseRank('3', '4', 4) // 乡镇街道
    // 六月
    this.teSeLiangDian('6', 0)
    this.qianTouDanWei('6', 1)
    this.elseRank('1', '6', 2)
    this.elseRank('2', '6', 3)
    this.elseRank('3', '6', 4)
    // 八月
    this.teSeLiangDian('8', 0)
    this.qianTouDanWei('8', 1)
    this.elseRank('1', '8', 2)
    this.elseRank('2', '8', 3)
    this.elseRank('3', '8', 4)
  },
  methods: {
    teSeLiangDian(month, index) {
      // 月份参数处理
      let newMonth;
      if (month === '6') {
        newMonth = '5-6'
      }
      if (month === '8') {
        newMonth = '7'
      }
      axios({
        method: 'post',
        url: 'https://lst.jiande.gov.cn:8443/competition_jiande/Digitization/getUnitList',
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        params: { month: newMonth || month }
      })
        .then(({data: {data}}) => {
          console.log('res', month, data);
          if (data) {
            this['rankList_' + month][index] = data
          }
        })
        .catch(err => {
          console.log('err', err);
        });
    },
    qianTouDanWei(month, index) {
      // 月份参数处理
      let newMonth;
      if (month === '6') {
        newMonth = '5-6'
      }
      if (month === '8') {
        newMonth = '7'
      }
      axios({
        method: 'post',
        url: 'https://lst.jiande.gov.cn:8443/competition_jiande/Digitization/comprehensive',
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        params: { month: newMonth || month }
      })
        .then(({data: {data}}) => {
          console.log('res', month, data);
          if (data) {
            this['rankList_' + month][index] = data
          }
        })
        .catch(err => {
          console.log('err', err);
        });
    },
    elseRank(list_type, month, index) {
      // 月份参数处理
      let newMonth;
      if (month === '6') {
        newMonth = '5-6'
      }
      if (month === '8') {
        newMonth = '7'
      }
      axios({
        method: 'post',
        url: 'https://lst.jiande.gov.cn:8443/competition_jiande/Digitization/getTownList',
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        params: { list_type, month: newMonth || month }
      })
        .then(({data: {data}}) => {
          console.log('res', month, data);
          if (data) {
            this['rankList_' + month][index] = data
          }
        })
        .catch(err => {
          console.log('err', err);
        });
    }
  }
};
</script>